package designPattern.memento.theaory;

public class Client {
    public static void main(String[] args) {

        Originator originator = new Originator();
        Caretaker caretaker = new Caretaker();

        originator.setState("状态1");
        //保存了当前状态
        caretaker.add(originator.savaStateMemento());

        originator.setState("状态2");
        caretaker.add(originator.savaStateMemento());

        originator.setState("状态3");
        caretaker.add(originator.savaStateMemento());

        //希望恢复到状态1
        System.out.println("当前状态是："+originator.getState());

        originator.getStateFromMemento(caretaker.get(0));
        System.out.println("恢复后状态是："+originator.getState());
    }
}
